package com.project.controller;
import com.project.bean.ShoppingCartBean;
import com.project.bean.UserBean;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;


@RestController
@RequestMapping("user")
public class UserController {
    /**主页面 */
    @Autowired
    private IUserService userService;
    /**登录*/
    @RequestMapping("login")
    public UserBean login(String userName, String password, HttpServletRequest request){
        UserBean user = userService.login(userName,password);
        if(user!=null){
            //在session中，绑定登录用户的共享数据
            request.getSession().setAttribute("loginUser",user);
        }
        return user;
    }
    @RequestMapping("test")
    public String test(){
        return "最后一次...";
    }


}
